<?php if ($additional) { ?>
    <?php foreach ($additional as $add) { ?>
        <?php if ($add->code) { ?>
            <?php if ($add->type == 'textarea') { ?>
                <div class="textarea">
                    <label for="additional_<?= $add->code ?>">
                        <?php
                        $title = unserialize($add->title);
                        $title = (isset($title[LANG])) ? $title[LANG] : ((LANG == 'ar') ? $title['en'] : $title['ar']);
                        echo $title;
                        ?> :</label>
                    <samp>
                        <textarea name="additional[<?= $add->code ?>]" id="additional_<?= $add->code ?>" placeholder="<?= $title ?>"><?php
                            if (form_val("additional=>$add->code"))
                                echo
                                form_val("additional=>$add->code");
                            else {
                                if (isset($prodadditional)) {
                                    foreach ($prodadditional as $prdadd) {
                                        if ($prdadd->code == $add->code) {
                                            echo $prdadd->value;
                                        }
                                    }
                                }
                            }
                            ?></textarea>
                    </samp>
                </div>
            <?php } elseif ($add->type == 'text') { ?>
                <div class="text">
                    <label for="additional_<?= $add->code ?>"><?php
                        $title = unserialize($add->title);
                        $title = (isset($title[LANG])) ? $title[LANG] : ((LANG == 'ar') ? $title['en'] : $title['ar']);
                        echo $title;
                        ?> :</label>
                    <samp>
                        <input type="text" name="additional[<?= $add->code ?>]" id="additional_<?= $add->code ?>" value="<?php
                        if (form_val("additional=>$add->code"))
                            echo
                            form_val("additional=>$add->code");
                        else {
                            if (isset($prodadditional)) {
                                foreach ($prodadditional as $prdadd) {
                                    if ($prdadd->code == $add->code) {
                                        echo $prdadd->value;
                                    }
                                }
                            }
                        }
                        ?>" placeholder="<?= $title ?>" autocomplete="off" >
                    </samp>
                </div>
            <?php } elseif ($add->type == 'list') { ?>
                <div class="select">
                    <label for="additional_<?= $add->code ?>"><?php
                        $title = unserialize($add->title);
                        $title = (isset($title[LANG])) ? $title[LANG] : ((LANG == 'ar') ? $title['en'] : $title['ar']);
                        echo $title;
                        ?> :</label>
                    <samp>
                        <select name="additional[<?= $add->code ?>]" id="additional_<?= $add->code ?>">
                            <?php
                            if (isset($prodadditional)) {
                                foreach ($prodadditional as $prdadd) {
                                    if ($prdadd->code == $add->code) {
                                        $database = $prdadd->value;
                                    }
                                }
                            }
                            ?>
                            <?php
                            $values = unserialize($add->data);
                            $values = (isset($values[LANG])) ? $values[LANG] : ((LANG == 'ar') ? $values['en'] : $values['ar']);
                            $values = explode('|', $values);
                            if ($values) {
                                foreach ($values as $key => $value) {
                                    ?>
                                    <option value="<?= $key ?>" <?php
                                    if (form_val("additional=>$add->code") == (string) $key)
                                        echo 'selected';
                                    elseif (isset($database))
                                        if ((string) $database == (string) $key)
                                            echo 'selected'
                                            ?>><?= $value ?></option>
                                            <?php
                                        }
                                    }
                                    ?>
                        </select>
                    </samp>
                </div>
            <?php }elseif ($add->type == 'checkbox') { ?>
                <div class="checkbox" style="padding: 5px 4px !important">
                    <label><?php
                        $title = unserialize($add->title);
                        $title = (isset($title[LANG])) ? $title[LANG] : ((LANG == 'ar') ? $title['en'] : $title['ar']);
                        echo $title;
                        ?> :</label>
                    <samp>
                        <?php
                        if (isset($prodadditional)) {
                            foreach ($prodadditional as $prdadd) {
                                if ($prdadd->code == $add->code) {
                                    $database = unserialize($prdadd->value);
                                }
                            }
                        }
                        ?>
                        <?php
                        $values = unserialize($add->data);
                        $values = (isset($values[LANG])) ? $values[LANG] : ((LANG == 'ar') ? $values['en'] : $values['ar']);
                        $values = explode('|', $values);
                        if ($values) {
                            $i = 0;
                            foreach ($values as $key => $value) {
                                ?>
                                <input type="checkbox" value="<?= $key ?>" name="additional[<?= $add->code ?>][]" id="additional_<?= $add->code . $key ?>" 
                                       <?php
                                       if ((string)form_val("additional=>$add->code=>".$key) == (string)$key)
                                           echo 'checked';
                                       elseif (isset($database)){
                                           if(is_array($database)) {
                                               if (in_array($key, $database))
                                                   echo 'checked';
                                           }
                                       }
                                       ?> /><label for="additional_<?= $add->code . $key ?>"><?= $value ?></label>
                                       <?php
                                   }
                               }
                               ?>
                    </samp>
                </div>
            <?php } ?>
        <?php } ?>
    <?php } ?>
<?php } ?>